<template>
	<view>
		<!-- 店铺联系方式弹窗 -->
		<view :class="'mask-content ' + (showMask ? 'active' :'')">
			<view class="title desc"><lang keywords="请选择联系客服的方式" chineseTxt="请选择联系客服的方式"></lang></view>
			<view class="list">
				<view class="desc" v-for="(item, index) in list" :key="index" @tap="callPhone(item)">{{item}}</view>
				<view class="desc" v-if="linkUrl" @tap="goUrl()">
					<lang keywords="在线客服" chineseTxt="在线客服"></lang>
				</view>
			</view>
			<button class="btn"  @click.stop="closeMask"><lang keywords="取消" chineseTxt="取消"></lang></button>
		</view>
		<view class="mask_bg" :hidden="!showMask" @tap="closeMask"></view>
	</view>
</template>

<script>
export default {
	name: 'call',
	data () {
		return {
			showMask: false
		}
	},
	props: {
		list: {
			type: Array,
			default: []
		},
		linkUrl: {
			type: String,
			default: ''
		},
		show: {
			type: Boolean,
			default: false
		}
	},
	watch: {
		show: {
			immediate: true,
			handler: function (val) {
				if (val) {
					this.showMask = true
				}
			}
		}
	},
	methods: {
		callPhone (phoneNumber) {
			wx.makePhoneCall({
				phoneNumber: phoneNumber
			});
			this.showMask = false
			this.$emit('showHandler', false)
		},
		closeMask () {
			this.showMask = false
			this.$emit('showHandler', false)
		},
		goUrl () {
			common.parseUrl(this.linkUrl, '', false, common.changeTxt('在线客服'));
		}
	}
}
</script>

<style scoped>
.mask_bg {
	position: fixed;
	z-index: 1000000000;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: #000;
	opacity: 0.5;
	
}

.mask-content {
	position: fixed;
	z-index: 1000000001;
	bottom: 0;
	left: 0;
	width: 100%;
	background: #fff;
	transition: all .3s ease;
	-webkit-transition: all .3s ease;
	transform: translate(0, 150%);
	-webkit-transform: translate(0, 150%)
}

.mask-content.active {
	transform: translate(0, 0);
	-webkit-transform: translate(0, 0)
}

.mask-content {
	padding: 10px;
	width: auto;
	background: transparent;
	right: 0;
	max-height: 70%;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	color: #333;
	font-size: 16px;
}
.mask-content .title{
	border-radius: 5px 5px 0 0;
}
.mask-content .desc{
	background: #fff;
	line-height: 2.55555556;
	border-bottom: 1px solid #f2f2f2;
	background: rgba(255, 255, 255, .98);
	text-align: center;
}
.mask-content .list{
	flex-grow: 1;
	overflow-y: auto;
	margin-bottom: 10px;
	border-radius: 0 0 5px 5px;
}
.mask-content .list .desc{
	color: #E73D43;
}
.mask-content .list .desc:last-child{
	border: none;
}
.mask-content .btn{
	font-size: 16px;
	width: 100%;
	background: rgba(255, 255, 255, .98);
	flex-shrink: 0;
}
</style>
